package cn.kgc.watch.service.impl;

import cn.kgc.watch.entity.Address;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import cn.kgc.watch.mapper.AddressMapper;
import cn.kgc.watch.service.AddressService;

import java.util.Date;
import java.util.List;

@Service
public class AddressServiceImpl implements AddressService{

    @Resource
    private AddressMapper addressMapper;

    @Override
    public List<Address> findAll() {
        return addressMapper.selectAll();
    }

    @Override
    public List<Address> findById(Integer id) {
        return addressMapper.selectById(id);
    }

    @Override
    public void modify(Address address) {
        address.setModifiedTime(new Date());
        addressMapper.update(address);
    }

    @Override
    public void remove(Integer id) {
        addressMapper.delete(id);
    }

    @Override
    public List<Address> findByUserId(Integer userId) {
        return this.addressMapper.selectByUserId(userId);

    }

    @Override
    public void add(Address address) {
        address.setCreateTime(new Date());
        this.addressMapper.insert(address);
    }
}
